package com.cskaoyan._12io._01bytestream._02fileinputstream;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @author Macro_Ray
 * @since 2024/3/21 21:50
 */
// 用一次多个字节的方式拷贝文件
public class FileCopyTest2 {
    public static void main(String[] args) throws IOException {
        // 1.创建对象
        FileInputStream fis = new FileInputStream("basketball1.mp4");
        FileOutputStream fos = new FileOutputStream("copy2.mp4");

        long start = System.currentTimeMillis();

        // 2.读写数据
        byte[] buffer = new byte[1024];
        int len;
        while ((len = fis.read(buffer)) != -1) {
            fos.write(buffer, 0, len);
        }

        // 3.释放资源
        fis.close();
        fos.close();

        long end = System.currentTimeMillis();
        System.out.println(end - start);

    }

}
